class Solution(object):
    def findMin(self, nums):
        begin = 0
        end = len(nums)-1
        while begin<end:
            mid = (begin+end)//2
            if nums[mid]>nums[begin] and nums[mid]>nums[end]:
                begin = mid
            elif nums[mid]<nums[begin] and nums[mid]<nums[end]:
                end = mid
            else:
                return min(nums[begin], nums[end])
        return nums[begin]
print(Solution().findMin([4,5,1,2,3]))